#!/bin/bash

! [ -n "$1" ] && echo "need config file path" && exit 1
! [ -n "${REDIS_PORT}" ] && exit 1

REPLACE_LINE=$(nl -b a $1 | grep -v '#' | grep -w  port | awk '{print $1}')

sed -i "${REPLACE_LINE}c port ${REDIS_PORT}" $1